package com.example.thealarm;

import static com.example.thealarm.MainActivity.musicFiles;
import static com.example.thealarm.TheSetPage.MusicPosition;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;

import androidx.core.app.NotificationCompat;

public class AlertReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        System.out.println("Now in here");
        System.out.println(MusicPosition);
        if(MusicPosition>0){
       Uri uri= Uri.parse(musicFiles.get(MusicPosition).getPath());
        MediaPlayer mediaPlayer= MediaPlayer.create(context.getApplicationContext(),uri);
        mediaPlayer.start();}
        NotificationHelper notificationHelper = new NotificationHelper(context);
        NotificationCompat.Builder nb =notificationHelper.getChannelNotification();
        notificationHelper.getManager().notify(1,nb.build());
    }
}
